home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
chang402.zip
/
CHANGE.DOC
< prev
next >
Wrap
Text File
|
1994-01-30
|
16KB
|
313 lines
CHANGE.DOC
01/30/94
The CHANGE.EXE program allows you to make changes in binary or text files of any
size. Features:
* Can handle files of any size provided you have enough room on your disk
to hold a copy of resulting file
* Can be used to change text files or binary files
* Can be used to remove trailing spaces from a file
* Can specify different lengths for the input strings and the output strings
* Can specify that the changes only be done in lines that include a certain
character string. This selection string can be case-insensitive
* Can handle up to 25 change requests at a time
* Can specify the input/output strings as ASCII characters, hexadecimal
values, or as decimal values
* Handles the changes fairly quickly
* Can either replace the original file with the resulting file or else
create a new changed file (using /Noutfile specification)
* Changes can be verified before they are made
* Changes can be entered in any of the following ways:
- from the command line (one TO/FROM pair allowed)
- interactively (one TO/FROM pair allowed)
- from a controlfile (up to 25 TO/FROM pairs allowed)
* Boolean operators can be used if the TO/FROM pair is specified from the
command line (e.g. CHANGE TEST.TXT /FROM One /TO Many /IN Apples OR Oranges
Program written by:
Bruce Guthrie
Room H-4885
U.S. Dept of Commerce/ESA/OBA/BSISD
Washington, D.C. 20230
(202) 482-3234
You may freely copy and re-distribute this program; however, the U.S.
Department of Commerce neither guarantees nor assures compatibility of the
program with all computer software or hardware.
Foreign users: Please provide an Internet address in all correspondence or
and just e-mail your problems to me at bgu@cu.nih.gov
Syntax:
CHANGE infile [ ctlfile | /Cctlfile |
/FROM string /TO string [ /IN search ] ]
[ /LINES { line1-line2 | line1 linect } ... ] [ /V | /-V ] [ /I | /-I ]
[ /Noutfile [ /OVERWRITE | /-OVERWRITE | /OVERASK ] ]
[ /Fflagfile ] [ /Ttempfile ] [ /TRIM | /-TRIM ]
[ /BINARY | /TEXT ] [ /VERIFY | /-VERIFY ] [ /Q ] [ /? | /?&H ]
where:
"infile" can include a drive and path designation. It is the file name you
want changed. Unless you specify a /Noutfile parameter, the infile will be
overwritten by this program.
"ctlfile" contains the change commands to make. If a ctlfile is not provided
and a FROM/TO option is not specified, the routine will prompt you for one FROM
(what's the text you want to change from; case is significant unless /CASE is
specified), TO (what's the text you want to change to; case is always
significant), and IN (what string the line must be contain before the change is
applied; case is always significant unless /CASE is specified) request. If a
ctlfile is used, you can specify up to 25 change requests at a time. Each line
of the change file should consist of records of one of four record types:
* blank lines or those beginning with semi-colons are treated as comments.
* lines beginning with "-F" or "-f" provide FROM options.
* lines beginning with "-T" or "-t" provide TO options.
* lines beginning with "-I" or "-i" provide IN options. These are optional;
if not provided, all lines will be searched for the FROM string. Any
IN request forces /TEXT mode to be invoked
If more than one set of FROM/TO/IN records is provided, the -F specification
must precede the others. Each option is local to a given FROM/TO/IN
specification. For example:
; Sample file
-FPRINT
-TPrinting
-I"
-fUSING
-tused
contains two FROM/TO/IN specifications. "PRINT" will be changed to "Printing"
in any line with a double quote. "USING" will be changed to "used" in all
lines; no -I option is applied for the second FROM/TO/IN specification.
The FROM/TO/IN specifications can include any text characters. They can also
contain ASCII codes, created either using the Alt key in combination with the
numeric keypad (e.g. Alt-228 to get a Sigma character) or else by imbedding a
hexadecimal code (in the form &Hxx) or a decimal code (in the form \nnn) in the
text. You can get a table of hexadecimal codes at the end of this documentation
or by saying "CHANGE /?&H". For example, to change a double carriage
return/line feed to a single carriage return/line feed, you could say:
-F&H0D0A0D0A
-T&H0D0A
(Note that the above example would require you to use the /BINARY option as well
since it extends beyond line boundaries.)
If you need to follow a hexadecimal specification with normal text characters,
follow the hex spec with one space (which CHANGE will ignore). For example,
-F&H0c Hi!
-T&H0d0a Bye!
"/Cctlfile" is the same as "ctlfile" separately but, unlike the letter,
"/Cctlfile" is not position dependent. It can appear anywhere in the command
line string.
"/FROM string /TO string [ /IN search ]" allows you to specify the from/to
parameters on the control line. Quotation marks are required around the strings
if they include spaces or special characters. Note that certain characters
cannot be passed in because DOS considers them special characters and steals
them first. This includes ">" and "|" characters. You'll have to use the
control file or the interactive mode in this case or else use the &Hxx or \nnn
conventions. "search" is further described below.
"/LINES line1-line2" says to restrict the search to lines between line numbers
line1 and line2 inclusive. You can have multiple line requests in any order
such as "/LINES 1-10 90-100 30-50". The routine skips all lines after the
largest line number is encountered. Defaults to "/LINES 1-9999999".
"/LINES line1 linect" says to restrict the search to lines beginning with line1
and continuing for a total of linect lines. So "/LINES 10 20" is actually the
same as "/LINES 10-29".
"/V" says to find those items that do NOT match the specification.
"/-V" is the opposite of /V and is typically the default; CONFIGWS-able.
"/I" says to make it a case-insensitive search.
"/-I" is the opposite of /I and is typically the default; CONFIGWS-able.
"/Noutfile" is the name of the new file to create. If a /Noutfile is not
specified, the source document (infile) will be replaced by the changed file.
"/OVERWRITE" says to write over the outfile (if requested) if it exists
already.
"/-OVERWRITE" says to abort if the outfile exists already.
"/OVERASK" says to ask if the outfile exists already. This is the default.
"/Fflagfile" is the name of a file to contain all changed lines. This allows
you to see what the lines were changed to for verification purposes. This
option automatically invokes /TEXT.
"/Ttempfile" is the name of the temporary file to create. The actual changes
are written to a temp file and then the source file is replaced with the temp
file is everything works and there were actually changes to be found in the
source document. By default, the temp file is written to the same path as the
input file. The temporary file will be as big as the final file is. If you
don't have enough room for it to be on your source disk, specify another
temporary file name with a different path (e.g. "/TG:\TEMP.TXT").
"/TRIM" says to remove trailing spaces from the end of each line. Automatically
forces you into TEXT mode.
"/-TRIM" is the opposite of /TRIM and is the default.
"/TEXT" puts you into TEXT mode. TEXT mode means that all data in the file are
read in and processed as separate text records. Alternatively, the file can be
processed in BINARY mode in which case the file is read in in 8,000-byte blocks.
BINARY mode is quicker and is required for EXE and COM files. TEXT mode
presents some information like the number of lines in your file and is
*required* if you specify any of the following options:
* an IN (or